<?php
/**
 * A test is an instance of CActiveRecord (sytem.db.ar). 
 *
 * CActiveRecord is the base class for classes representing relational data. 
 *
 * Eduow :  International system for education (http://www.eduow.com)
 * Copyright 2010, Nikolay Stoitsev and Ivailo Danev
 *
 * Licensed under GNU General Public License version 2
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2010
 * @link          http://eduow.com Eduow Project
 * @package       eduow
 * @subpackage    application.models
 * @inheritance   class test >> CActiveRecord >> CModel >> CComponent
 * @implements    ArrayAccess, Traversable, IteratorAggregate
 * @since         Eduow v 0.0.3
 * @license       http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License version 2
 *                http://bulgaria.sourceforge.net/prava/gplbg.html GNU General Public License version 2
 */


class Test extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'test':
	 * @var integer $id
	 * @var string $test1
	 * @var integer $test2
	 * @var integer $test4
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'test';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('test1', 'required'),
			array('test2, test4', 'numerical', 'integerOnly'=>true),
			array('test1', 'length', 'max'=>200),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, test1, test2, test4', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => Yii::t('yii','Id'),
			'test1' => Yii::t('yii','Test1'),
			'test2' => Yii::t('yii','Test2'),
			'test4' => Yii::t('yii','Test4'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);

		$criteria->compare('test1',$this->test1,true);

		$criteria->compare('test2',$this->test2);

		$criteria->compare('test4',$this->test4);

		return new CActiveDataProvider('test', array(
			'criteria'=>$criteria,
		));
	}
}
